package com.example.itcacp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.itcacp.entity.Collect;
import com.example.itcacp.entity.Like;
import com.example.itcacp.repository.mybatis.CollectMapper;
import com.example.itcacp.service.CollectService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CollectServiceImpl extends ServiceImpl<CollectMapper, Collect> implements CollectService {

   @Resource
   private CollectMapper collectMapper;
   /**
    * 添加收藏记录
    * */
    @Override
    public void addCollect(Collect collect) {
        collectMapper.insert ( collect );
    }

    /**
     * 分页查询用户收藏的记录
     * */
    @Override
    public PageInfo<Collect> selectUserCollectPage(Integer pageNum, Integer pageSize, Long userId) {
        PageHelper.startPage ( pageNum, pageSize );
        List<Collect> collectsByUserId = collectMapper.getCollectsByUserId ( userId );
        return PageInfo.of ( collectsByUserId );
    }
}
